********************************************************************************
* File for replicating all numbers and figures in the article 				   *
* "Obstacles to Electoral Participation as Experienced by Individuals with     *
* Intellectual Disability"													   *
********************************************************************************

	clear all
	macro drop _all

* Set your macros for input and output. N.B: the paths are redacted and need adjustment
	global input "--- redacted ---"
	global out "--- redacted ---"

* Get data
	use "$input\Replication data for Obstacles to Electoral Participation as Experienced by Individuals with Intellectual Disability.dta"

	
*********************************************************************************
*								Calculations for the article 					*
*********************************************************************************
	
**************************
* Number of participants, circles, and facilitators
		tab Number_Obstacles // 326 participants gave answers about obstacles
		
		ssc install distinct
		* Groups
		distinct Group // 95 Groups in which participants gave answers about obstacles to voting

		* Facilitator
		distinct Facilitator // 32 facilitators for these 95 groups


**************************
* Sample Characteristics *
* Mentioned in the running text, also reported i Online Supplemental material, Table 1.

* Age, genderm and migration background
		sum V45_Age // Mean 37.56, range 19-70.
		
		tab V44_Gender // 59.87 % men, 37.79 % women, 0.33 % other and 2.01 percent did not want to answer.

		tab V46_Born_In_Sweden // 11.74 percent born abroad, 87.58 percent born in Sweden, 0.67 percent did not want to answer. There was also a "don't know" option, which no one picked.

* Housing 
		sum Lives_Supported_Housing // 52.54 %

		sum Lives_Own_Housing // 29.83 %

		sum Lives_Only_With_Parents // 16.61 %

*  Occupation status	
		sum V47_2_Activity_Center // 92.54 %
		sum Pension_Or_Sick // 26.44 %
		sum V47_1_Studies // 8.50 %
		sum Work_Not_Activity_Center // 7.12 %
	
* Reading 
		sum Reading_Positive	
	
* Difficulties - preparation
	*Number of difficulties
		gen Number_Of_Difficulties = 0
		replace Number_Of_Difficulties = (V51_2 + V51_3 + V51_4 + V51_5 + V51_6 + ///
		V51_7 + V51_8 + V51_9 + V51_10 + V51_11 + V51_12 + V51_13_) 
		label var Number_Of_Difficulties "No. of diffic. (0-12)"
		
	* Neuropsychiatric
		egen Diff_Neuropsychiatric = rowmean(V51_3_Difficulties_Concentration ///
		V51_4_Difficulties_Memory V51_5_Difficulties_Get_Started V51_6_Difficulties_Completing ///
		V51_7_Difficulties_Planning) // Index 0-1 for the share of listed NP related difficulties that the resp. has indicated.
		
		gen Diff_NP_Dummy = . // Dummy that indicates wheter the resp. has indicated at least one NP related difficulty.
		replace Diff_NP_Dummy = 1 if Diff_Neuropsychiatric > 0
		replace Diff_NP_Dummy = 0 if Diff_Neuropsychiatric == 0
		replace Diff_NP_Dummy = . if Diff_Neuropsychiatric == .
		label var Diff_NP_Dummy "Neuropsychiatric difficulties"

	* Language
		egen Diff_Language = rowmean(V51_2_Difficulties_Communication V51_8_Difficulties_Reading ///
		V51_9_Difficulties_Writing V51_10_Difficulties_Calculating) // Index 0-1 for the share of listed language related difficulties that the resp. has indicated.
			
		gen Diff_Lang_Dummy = . // Dummy that indicates wheter the resp. has indicated at least one language related difficulty.
		replace Diff_Lang_Dummy = 1 if Diff_Language > 0
		replace Diff_Lang_Dummy = 0 if Diff_Language == 0
		replace Diff_Lang_Dummy = . if Diff_Language == .
		label var Diff_Lang_Dummy "Difficulties with language"
		
	* Intellectual
		egen Diff_Intellectual = rowmean(V51_11_Difficulties_Understand V51_12_Difficulties_Learning_New) 
		// Index 0-1 for the share of listed intellectual difficulties that the resp. has indicated.
			
		gen Diff_I_Dummy = . // D// Dummy that indicates wheter the resp. has indicated at least one intellectual difficulty.
		replace Diff_I_Dummy = 1 if Diff_Intellectual > 0
		replace Diff_I_Dummy = 0 if Diff_Intellectual == 0
		replace Diff_I_Dummy = . if Diff_Intellectual == .
		label var Diff_I_Dummy "Intellectual difficulties"
		
* Difficulties - summarizing
		sum Number_Of_Difficulties // 3.68
		sum Diff_NP_Dummy // 76 %
		sum Diff_Lang_Dummy // 61 %
		sum Diff_I_Dummy // 47 %

* Help received in everyday life
		sum V48_1_Manage_On_My_Own // 22.63 %
		sum Help_Family // 53.37 %
		sum Help_Friend // 32.77 %
		sum Help_Appointed // 61.82 %
		sum V48_9_Help_From_Housing_Staff // 58.45 %

	
************************************
* Obstacles Expressed after Election Day 

	* Preparations*
	
		* A variable that indicates that the resp. has:
		// - indicated that nothing was difficult (by ticking that box)
		// - AND not indicated any experienced obstacle (by ticking those boxes)

			gen No_Obstacle=.
			replace No_Obstacle=1 if V19_19==1 & Number_Obstacles==0
			replace No_Obstacle=0 if V19_19==0 
			replace No_Obstacle=0 if Number_Obstacles>0 & Number_Obstacles!=.

		* Variables for experienced obstacles
			* Dichotomous - having experienced none or some obstacle within the category
			* Indices - experienced share of obstacles within the category

			* Making the decision
				gen Making_The_Decision_D=. // D for dummy
				replace Making_The_Decision_D=1 if V19_1_Difficult_To_Choose_Party + V19_2 + V19_3 + V19_4 > 0 & V19_1_Difficult_To_Choose_Party < 90
				replace Making_The_Decision_D=0 if V19_1_Difficult_To_Choose_Party + V19_2 + V19_3_No_Party_Thought_like_me + V19_4==0
					
				egen Making_The_Decision_I = rowmean (V19_1_Difficult_To_Choose_Party V19_2 V19_3_No_Party_Thought_like_me V19_4) // I for index
					
			* Getting to a polling station
				gen Getting_There_D=.
				replace Getting_There_D=1 if V19_5 + V19_6 + V19_7 + V19_8 + V19_9 > 0 & V19_5 < 90
				replace Getting_There_D=0 if V19_5 + V19_6 + V19_7 + V19_8 + V19_9==0

				egen Getting_There_I = rowmean (V19_5 V19_6 V19_7 V19_8 V19_9)

			* At the polling station
				gen The_Polling_Station_D=.
				replace The_Polling_Station_D=1 if V19_13 + V19_14 + V19_15 + V19_16 + V19_17 > 0 & V19_5 < 90
				replace The_Polling_Station_D=0 if V19_13 + V19_14 + V19_15 + V19_16 + V19_17==0

				egen The_Polling_Station_I = rowmean (V19_13 V19_14 V19_15 V19_16 V19_17)
				
			* Perceived legal obstacles
				gen Perceived_Legal_Obstacles_D=.
				replace Perceived_Legal_Obstacles_D=1 if V19_10 + V19_11 > 0 & V19_10 < 90
				replace Perceived_Legal_Obstacles_D=0 if V19_10 + V19_11==0

				egen Perceived_Legal_Obstacles_I = rowmean (V19_10 V19_11)
							
	* Frequency of categorized difficulties

			ttest Making_The_Decision_D, by (V16_Voted) 
			ttest Getting_There_D, by (V16_Voted) 
			ttest The_Polling_Station_D, by (V16_Voted) 
			ttest V19_12, by (V16_Voted) 
			ttest Perceived_Legal_Obstacles_D, by (V16_Voted)  
			ttest V19_18_1, by (V16_Voted) 
			ttest No_Obstacle, by (V16_Voted)  
		
		* Significance test of differences in pobability that voters and non-voters, respectivelför, 
		// experience each kind of obstacles. 
		// Calculated by regression on dummy variables in order to cluster on groups.
		
				reg Making_The_Decision_D V16_Voted, cl(Group)

				reg Getting_There_D V16_Voted, cl(Group)

				reg The_Polling_Station_D V16_Voted, cl(Group)

				reg V19_12 V16_Voted, cl(Group)

				reg Perceived_Legal_Obstacles_D V16_Voted, cl(Group)
				
				reg V19_18_1 V16_Voted, cl(Group)
				
				reg No_Obstacle V16_Voted, cl(Group)

	* Excel sheet with all experienced obstacles to voting. (This is also turned into Figure 2 in the Online Supplemental Material)
		tabout No_Obstacle using "$out\Which_Obstacles.txt", cells(freq col) replace
		tabout V19_1_Difficult_To_Choose_Party using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_2 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_3 using "$out\Which_Obstacles.txt", cells(freq col) append 
		tabout V19_4 using "$out\Which_Obstacles.txt", cells(freq col) append 
		tabout V19_5 using "$out\Which_Obstacles.txt", cells(freq col) append 
		tabout V19_6 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_7 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_8 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_9 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_10 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_11 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_12 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_13 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_14 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_15 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_16 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_17 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_18_1 using "$out\Which_Obstacles.txt", cells(freq col) append
		tabout V19_19 using "$out\Which_Obstacles.txt", cells(freq col) append

		* Additional number: share of persons living at a group home who indicated that the staff didnt want to help them: 
		tab V19_6 if Lives_Supported_Housing == 1
		
	* Share of respondents who voted
		tab V16_Voted


*********************************************************************************
*								Online supplemental material 					*
*********************************************************************************

************
* Figure 1 *
************
	
	set scheme Lean1
	graph set window fontface "Arial" 
	
	label var V45_Age "Age"
	sum V45_Age

	hist V45, start (15) width (5) color(dkgreen*.7) freq addlabels  addlabopts(yvarformat(%9.0f)) ///
	title ("Distribution of age") subtitle("N=292 persons") ///
	xtitle ("Age") ytitle ("Respondents") xlabel(20(10)80) yscale (range(0 70))
	graph export "$out\Age_histogram.tif", width (2550) replace


***********
* Table 1 *
***********

	// See "Sample characteristics" at row 32 above. 


************
* Figure 2 *
************

	// The numbers produced by the ttests from row 165 were turned into a diagram in Excel,
	// which is not included here.
	// All numbers and the significance tests (by regressions) are to be found from row 165.


**************************************************************************************
* Table 2. Linear probability model of having experinced categories of difficulties. * 
**************************************************************************************

	la var V16_Voted "Voted (Yes=1)"

	reg Making_The_Decision_D V16_Voted, cl(Group)
	eststo Make_decision, title (Making the decision)

	reg Getting_There_D V16_Voted, cl(Group)
	eststo Getting_there, title (Getting there)

	reg The_Polling_Station_D V16_Voted, cl(Group)
	eststo Polling_station, title (Polling station)

	reg V19_12 V16_Voted, cl(Group)
	eststo Lack_of_reasons, title (Lack of reasons)

	reg Perceived_Legal_Obstacles_D V16_Voted, cl(Group)
	eststo Perceived_legal, title (Perceived legal obstacles)
	
	reg V19_18_1 V16_Voted, cl(Group)
	eststo Other_difficulty, title (Other difficulty)
	
	reg No_Obstacle V16_Voted, cl(Group)
	eststo No_difficulty, title (No difficulty)

	esttab Make_decision Getting_there Polling_station Lack_of_reasons Perceived_legal Other_difficulty No_difficulty ///
	using "$out\Differences_Voters_Non_Voters.rtf", cells(b(star fmt(3)) se(par fmt(3))) ///
	noobs nonumber mtitles starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label legend collabels("") replace

	
**********************************************************************************************
* Table 3, Indices for experienced difficulties in voting regressed on background variables. *
**********************************************************************************************

	* // Labels for indices:
		label var Diff_Neuropsychiatric "Neuropsychiatric difficulties"
		label var Diff_Language "Difficulties with language"
		label var Diff_Intellectual "Intellectual difficulties"

	* Dummies for gender and migration background

		recode V44_Gender (1 3 = 0) (2 = 1) (4 = .), gen(Woman)
		label var Woman "Female"
		
		recode V46_Born_In_Sweden (0 = 0) (1 = 1) (3 4 =.), gen(Native)
		label var Native "Born in Sweden"
	
	* Standardization of independent variables

		ssc install center, replace

		center Diff_Intellectual Diff_Neuropsychiatric Diff_Language Reading_Positive Number_Of_Difficulties V48_1_Manage_On_My_Own Help_Family Help_Friend Help_Appointed V48_9_Help_From_Housing_Staff Occupation_Not_Activity_Center Lives_Own_Housing Lives_Supported_Housing Lives_Only_With_Parents Woman Native V45_Age, standardize addtolabel("")

	* Standardization of dependent variables
		center Making_The_Decision_I Getting_There_I The_Polling_Station_I V19_12 Perceived_Legal_Obstacles_I, standardize addtolabel("")
		
	* The table
		* Step one. Creating a file with headers and the upper row (intellectual difficulties)

		foreach var in Diff_Intellectual {
			reg c_Making_The_Decision_I c_`var', cl(Group)
			eststo Make_decision, title (Making the decision)

			reg c_Getting_There_I c_`var', cl(Group)
			eststo Getting_there, title (Getting there)

			reg c_The_Polling_Station_I c_`var', cl(Group)
			eststo Polling_station, title (Polling station)

			reg c_V19_12 c_`var', cl(Group)
			eststo Lack_of_reasons, title (Lack of reasons)

			reg c_Perceived_Legal_Obstacles_I c_`var', cl(Group)
			eststo Perceived_legal, title (Perceived legal obstacles)

			esttab Make_decision Getting_there Polling_station Lack_of_reasons Perceived_legal ///
		using "$out\Bivariatasamband.rtf", cells(b(star fmt(3)) se(par fmt(3))) drop(_cons) nonumber ///
		noobs mtitles nonote starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label collabels("") replace
		}

		* Step two. Appending to the file with the folowing rows, except the last.	
		// Global for all independent variables except the first and the last.
		global bakgrund "Diff_Neuropsychiatric Diff_Language Number_Of_Difficulties Reading_Positive V48_1_Manage_On_My_Own Help_Family Help_Friend Help_Appointed V48_9_Help_From_Housing_Staff Occupation_Not_Activity_Center Lives_Own_Housing Lives_Supported_Housing Lives_Only_With_Parents Woman Native"
		// NB that categories of difficulties (intellectual, neuropsychiatric, and language) are operationalized by indices. 
			
		foreach var in $bakgrund {
			reg c_Making_The_Decision_I c_`var', cl(Group)
			eststo Make_decision, title (Making the decision)

			reg c_Getting_There_I c_`var', cl(Group)
			eststo Getting_there, title (Getting there)

			reg c_The_Polling_Station_I c_`var', cl(Group)
			eststo Polling_station, title (Polling station)

			reg c_V19_12 c_`var', cl(Group)
			eststo Lack_of_reasons, title (Lack of reasons)

			reg c_Perceived_Legal_Obstacles_I c_`var', cl(Group)
			eststo Perceived_legal, title (Perceived legal obstacles)
		
			esttab Make_decision Getting_there Polling_station Lack_of_reasons Perceived_legal ///
		using "$out\Bivariatasamband.rtf", cells(b(star fmt(3)) se(par fmt(3))) drop(_cons) ///
		noobs nonumber nomtitles nonote starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label collabels("") append
		}
			
		* Step three. The last independent variable (age) and end comments.	

		foreach var in V45 {
			reg c_Making_The_Decision_I c_`var', cl(Group)
			eststo Make_decision, title (Making the decision)

			reg c_Getting_There_I c_`var', cl(Group)
			eststo Getting_there, title (Getting there)

			reg c_The_Polling_Station_I c_`var', cl(Group)
			eststo Polling_station, title (Polling station)

			reg c_V19_12 c_`var', cl(Group)
			eststo Lack_of_reasons, title (Lack of reasons)

			reg c_Perceived_Legal_Obstacles_I c_`var', cl(Group)
			eststo Perceived_legal, title (Perceived legal obstacles)

			esttab Make_decision Getting_there Polling_station Lack_of_reasons Perceived_legal ///
		using "$out\Bivariatasamband.rtf", cells(b(star fmt(3)) se(par fmt(3))) drop(_cons) ///
		noobs nonumber nomtitles starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label legend collabels("") append
		}	

* Do-file compelete.	